<?php

class input{
    function post($key){
        if(isset($_POST[$key])===false){
            return false;
        }
        $val=$_POST[$key];
        return $val;
    }
    function get($key){
        if(isset($_GET[$key])===false){
            return false;
        }
        $val=$_GET[$key];
        return $val;
    }
}
include ('shuju.php');
session_start();
$input=new input();
$act=$input->get('act');

if($act!==false){
    $user=$input->post('user');
    $password=$input->post('password');
    $login="SELECT *FROM login WHERE user='{$user}' AND PASSWORD='{$password}'";
    $mysqli_result=$link->query($login);

    if($row=$mysqli_result->fetch_array()){
       $_SESSION['user'] = $row['user'];
       header('location:1.php');
    }
    else{
        echo '登陆失败';
        exit;
    }
}

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>管理员登录</title>
</head>
<body>
    <form action="login.php?act=chk" method="post">
        <input type="text" name="user" />
        <input type="password" name="password">
        <input type="submit" value="登录">
    </form>
</body>
</html>
